<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>废除脚本缓存</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.opcache-get-status.html">« opcache_get_status</a></li>
      <li style="float: right;"><a href="function.opcache-is-script-cached.html">opcache_is_script_cached »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.opcache.html">OPcache 函数</a></li>
    <li>废除脚本缓存</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.opcache-invalidate" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">opcache_invalidate</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7, PHP 8, PECL ZendOpcache &gt;= 7.0.0)</p><p class="refpurpose"><span class="refname">opcache_invalidate</span> &mdash; <span class="dc-title">废除脚本缓存</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.opcache-invalidate-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>opcache_invalidate</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$force</code><span class="initializer"> = <strong><code>false</code></strong></span></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   该函数的作用是使得指定脚本的字节码缓存失效。如果 <code class="parameter">force</code> 没有设置或者传入的是
   <strong><code>false</code></strong>，那么只有当脚本的修改时间比对应字节码的时间更新，脚本的缓存才会失效。此函数仅使内存缓存无效，而不是文件缓存。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.opcache-invalidate-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">filename</code></dt>

    <dd>

     <p class="para">
      缓存需要被作废对应的脚本路径
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">force</code></dt>

    <dd>

     <p class="para">
      如果该参数设置为<strong><code>true</code></strong>，那么不管是否必要，该脚本的缓存都将被废除。
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.opcache-invalidate-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   如果 <code class="parameter">filename</code> 的字节码缓存失效设置成功或者该脚本本来就没有缓存，则返回
   <strong><code>true</code></strong>；如果字节码缓存被禁用，则返回<strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.opcache-invalidate-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.opcache-compile-file.html" class="function" rel="rdfs-seeAlso">opcache_compile_file()</a> - 无需运行，即可编译并缓存 PHP 脚本</span></li>
    <li class="member"><span class="function"><a href="function.opcache-reset.html" class="function" rel="rdfs-seeAlso">opcache_reset()</a> - 重置字节码缓存的内容</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>